<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Psych::Visitors::ToRuby - psych: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Visitor.html">Psych::Visitors::Visitor</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-create">::create</a>
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li class="calls-super" ><a href="#method-i-accept">#accept</a>
    <li ><a href="#method-i-build_exception">#build_exception</a>
    <li ><a href="#method-i-deduplicate">#deduplicate</a>
    <li ><a href="#method-i-deserialize">#deserialize</a>
    <li ><a href="#method-i-init_with">#init_with</a>
    <li ><a href="#method-i-merge_key">#merge_key</a>
    <li ><a href="#method-i-register">#register</a>
    <li ><a href="#method-i-register_empty">#register_empty</a>
    <li ><a href="#method-i-resolve_class">#resolve_class</a>
    <li ><a href="#method-i-revive">#revive</a>
    <li ><a href="#method-i-revive_hash">#revive_hash</a>
    <li ><a href="#method-i-visit_Psych_Nodes_Alias">#visit_Psych_Nodes_Alias</a>
    <li ><a href="#method-i-visit_Psych_Nodes_Document">#visit_Psych_Nodes_Document</a>
    <li ><a href="#method-i-visit_Psych_Nodes_Mapping">#visit_Psych_Nodes_Mapping</a>
    <li ><a href="#method-i-visit_Psych_Nodes_Scalar">#visit_Psych_Nodes_Scalar</a>
    <li ><a href="#method-i-visit_Psych_Nodes_Sequence">#visit_Psych_Nodes_Sequence</a>
    <li ><a href="#method-i-visit_Psych_Nodes_Stream">#visit_Psych_Nodes_Stream</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Psych::Visitors::ToRuby">
    <h1 id="class-Psych::Visitors::ToRuby" class="class">
      class Psych::Visitors::ToRuby
    </h1>

    <section class="description">
    
<p>This class walks a YAML AST, converting each node to Ruby</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-class_loader" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">class_loader</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-create" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create</span><span
                                class="method-args">(symbolize_names: false, freeze: false, strict_integer: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="create-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 15</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">create</span>(<span class="ruby-value">symbolize_names:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">freeze:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">strict_integer:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">class_loader</span> = <span class="ruby-constant">ClassLoader</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">scanner</span>      = <span class="ruby-constant">ScalarScanner</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">class_loader</span>, <span class="ruby-value">strict_integer:</span> <span class="ruby-identifier">strict_integer</span>
  <span class="ruby-identifier">new</span>(<span class="ruby-identifier">scanner</span>, <span class="ruby-identifier">class_loader</span>, <span class="ruby-value">symbolize_names:</span> <span class="ruby-identifier">symbolize_names</span>, <span class="ruby-value">freeze:</span> <span class="ruby-identifier">freeze</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(ss, class_loader, symbolize_names: false, freeze: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span> <span class="ruby-identifier">ss</span>, <span class="ruby-identifier">class_loader</span>, <span class="ruby-value">symbolize_names:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">freeze:</span> <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">super</span>()
  <span class="ruby-ivar">@st</span> = {}
  <span class="ruby-ivar">@ss</span> = <span class="ruby-identifier">ss</span>
  <span class="ruby-ivar">@load_tags</span> = <span class="ruby-constant">Psych</span>.<span class="ruby-identifier">load_tags</span>
  <span class="ruby-ivar">@domain_types</span> = <span class="ruby-constant">Psych</span>.<span class="ruby-identifier">domain_types</span>
  <span class="ruby-ivar">@class_loader</span> = <span class="ruby-identifier">class_loader</span>
  <span class="ruby-ivar">@symbolize_names</span> = <span class="ruby-identifier">symbolize_names</span>
  <span class="ruby-ivar">@freeze</span> = <span class="ruby-identifier">freeze</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-accept" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">accept</span><span
                                class="method-args">(target)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="Visitor.html#method-i-accept"><code>Psych::Visitors::Visitor#accept</code></a>
                              </div>

                              <div class="method-source-code" id="accept-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">accept</span> <span class="ruby-identifier">target</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-keyword">super</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@domain_types</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-identifier">target</span>.<span class="ruby-identifier">tag</span>
    <span class="ruby-identifier">key</span> = <span class="ruby-identifier">target</span>.<span class="ruby-identifier">tag</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^[!\/]*/</span>, <span class="ruby-string">&#39;&#39;</span>).<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/(,\d+)\//</span>, <span class="ruby-string">&#39;\1:&#39;</span>)
    <span class="ruby-identifier">key</span> = <span class="ruby-node">&quot;tag:#{key}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(?:tag:|x-private)/</span>

    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@domain_types</span>.<span class="ruby-identifier">key?</span> <span class="ruby-identifier">key</span>
      <span class="ruby-identifier">value</span>, <span class="ruby-identifier">block</span> = <span class="ruby-ivar">@domain_types</span>[<span class="ruby-identifier">key</span>]
      <span class="ruby-identifier">result</span> = <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">value</span>, <span class="ruby-identifier">result</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">deduplicate</span>(<span class="ruby-identifier">result</span>).<span class="ruby-identifier">freeze</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@freeze</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-visit_Psych_Nodes_Alias" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">visit_Psych_Nodes_Alias</span><span
                                class="method-args">(o)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="visit_Psych_Nodes_Alias-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 327</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">visit_Psych_Nodes_Alias</span> <span class="ruby-identifier">o</span>
  <span class="ruby-ivar">@st</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">anchor</span>) { <span class="ruby-identifier">raise</span> <span class="ruby-constant">AnchorNotDefined</span>, <span class="ruby-identifier">o</span>.<span class="ruby-identifier">anchor</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-visit_Psych_Nodes_Document" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">visit_Psych_Nodes_Document</span><span
                                class="method-args">(o)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="visit_Psych_Nodes_Document-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 319</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">visit_Psych_Nodes_Document</span> <span class="ruby-identifier">o</span>
  <span class="ruby-identifier">accept</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">root</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-visit_Psych_Nodes_Mapping" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">visit_Psych_Nodes_Mapping</span><span
                                class="method-args">(o)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="visit_Psych_Nodes_Mapping-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 165</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">visit_Psych_Nodes_Mapping</span> <span class="ruby-identifier">o</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@load_tags</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>]
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">revive</span>(<span class="ruby-identifier">resolve_class</span>(<span class="ruby-ivar">@load_tags</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>]), <span class="ruby-identifier">o</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">revive_hash</span>(<span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, {}), <span class="ruby-identifier">o</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!ruby\/struct:?(.*)?$/</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>) <span class="ruby-keyword">if</span> <span class="ruby-node">$1</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span>
      <span class="ruby-identifier">s</span> = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>)

      <span class="ruby-identifier">members</span> = {}
      <span class="ruby-identifier">struct_members</span> = <span class="ruby-identifier">s</span>.<span class="ruby-identifier">members</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">symbolize</span> <span class="ruby-identifier">x</span> }
      <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">member</span> = <span class="ruby-identifier">accept</span>(<span class="ruby-identifier">k</span>)
        <span class="ruby-identifier">value</span>  = <span class="ruby-identifier">accept</span>(<span class="ruby-identifier">v</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">struct_members</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">symbolize</span>(<span class="ruby-identifier">member</span>))
          <span class="ruby-identifier">s</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{member}=&quot;</span>, <span class="ruby-identifier">value</span>)
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">members</span>[<span class="ruby-identifier">member</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^@/</span>, <span class="ruby-string">&#39;&#39;</span>)] = <span class="ruby-identifier">value</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">init_with</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">members</span>, <span class="ruby-identifier">o</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">struct</span>
      <span class="ruby-identifier">members</span> = <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }
      <span class="ruby-identifier">h</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">members</span>]
      <span class="ruby-identifier">s</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">h</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">symbolize</span> <span class="ruby-identifier">k</span>
      }).<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">h</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> })
      <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">s</span>)
      <span class="ruby-identifier">s</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!ruby\/object:?(.*)?$/</span>
    <span class="ruby-identifier">name</span> = <span class="ruby-node">$1</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;Object&#39;</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;Complex&#39;</span>
      <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">complex</span>
      <span class="ruby-identifier">h</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }]
      <span class="ruby-identifier">register</span> <span class="ruby-identifier">o</span>, <span class="ruby-constant">Complex</span>(<span class="ruby-identifier">h</span>[<span class="ruby-string">&#39;real&#39;</span>], <span class="ruby-identifier">h</span>[<span class="ruby-string">&#39;image&#39;</span>])
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;Rational&#39;</span>
      <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">rational</span>
      <span class="ruby-identifier">h</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }]
      <span class="ruby-identifier">register</span> <span class="ruby-identifier">o</span>, <span class="ruby-constant">Rational</span>(<span class="ruby-identifier">h</span>[<span class="ruby-string">&#39;numerator&#39;</span>], <span class="ruby-identifier">h</span>[<span class="ruby-string">&#39;denominator&#39;</span>])
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;Hash&#39;</span>
      <span class="ruby-identifier">revive_hash</span>(<span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, {}), <span class="ruby-identifier">o</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">revive</span>((<span class="ruby-identifier">resolve_class</span>(<span class="ruby-identifier">name</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">object</span>), <span class="ruby-identifier">o</span>)
      <span class="ruby-identifier">obj</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!(?:str|ruby\/string)(?::(.*))?$/</span>, <span class="ruby-string">&#39;tag:yaml.org,2002:str&#39;</span>
    <span class="ruby-identifier">klass</span>   = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>)
    <span class="ruby-identifier">members</span> = {}
    <span class="ruby-identifier">string</span>  = <span class="ruby-keyword">nil</span>

    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">key</span>   = <span class="ruby-identifier">accept</span> <span class="ruby-identifier">k</span>
      <span class="ruby-identifier">value</span> = <span class="ruby-identifier">accept</span> <span class="ruby-identifier">v</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;str&#39;</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span>
          <span class="ruby-identifier">string</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>.<span class="ruby-identifier">replace</span> <span class="ruby-identifier">value</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">string</span> = <span class="ruby-identifier">value</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">string</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">members</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">init_with</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">members</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^@/</span>, <span class="ruby-string">&#39;&#39;</span>),<span class="ruby-identifier">v</span>] }, <span class="ruby-identifier">o</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!ruby\/array:(.*)$/</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>)
    <span class="ruby-identifier">list</span>  = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>)

    <span class="ruby-identifier">members</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>).<span class="ruby-identifier">to_a</span>]
    <span class="ruby-identifier">list</span>.<span class="ruby-identifier">replace</span> <span class="ruby-identifier">members</span>[<span class="ruby-string">&#39;internal&#39;</span>]

    <span class="ruby-identifier">members</span>[<span class="ruby-string">&#39;ivars&#39;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ivar</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">list</span>.<span class="ruby-identifier">instance_variable_set</span> <span class="ruby-identifier">ivar</span>, <span class="ruby-identifier">v</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">list</span>

  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;!ruby/range&#39;</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">range</span>
    <span class="ruby-identifier">h</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }]
    <span class="ruby-identifier">register</span> <span class="ruby-identifier">o</span>, <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">h</span>[<span class="ruby-string">&#39;begin&#39;</span>], <span class="ruby-identifier">h</span>[<span class="ruby-string">&#39;end&#39;</span>], <span class="ruby-identifier">h</span>[<span class="ruby-string">&#39;excl&#39;</span>])

  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!ruby\/exception:?(.*)?$/</span>
    <span class="ruby-identifier">h</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }]

    <span class="ruby-identifier">e</span> = <span class="ruby-identifier">build_exception</span>((<span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">exception</span>),
                        <span class="ruby-identifier">h</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;message&#39;</span>))

    <span class="ruby-identifier">e</span>.<span class="ruby-identifier">set_backtrace</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;backtrace&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">key?</span> <span class="ruby-string">&#39;backtrace&#39;</span>
    <span class="ruby-identifier">init_with</span>(<span class="ruby-identifier">e</span>, <span class="ruby-identifier">h</span>, <span class="ruby-identifier">o</span>)

  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;!set&#39;</span>, <span class="ruby-string">&#39;tag:yaml.org,2002:set&#39;</span>
    <span class="ruby-identifier">set</span> = <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">psych_set</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-ivar">@st</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">anchor</span>] = <span class="ruby-identifier">set</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">anchor</span>
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">set</span>[<span class="ruby-identifier">accept</span>(<span class="ruby-identifier">k</span>)] = <span class="ruby-identifier">accept</span>(<span class="ruby-identifier">v</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">set</span>

  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!ruby\/hash-with-ivars(?::(.*))?$/</span>
    <span class="ruby-identifier">hash</span> = <span class="ruby-node">$1</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>).<span class="ruby-identifier">allocate</span> <span class="ruby-operator">:</span> {}
    <span class="ruby-identifier">register</span> <span class="ruby-identifier">o</span>, <span class="ruby-identifier">hash</span>
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">value</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;elements&#39;</span>
        <span class="ruby-identifier">revive_hash</span> <span class="ruby-identifier">hash</span>, <span class="ruby-identifier">value</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;ivars&#39;</span>
        <span class="ruby-identifier">value</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">instance_variable_set</span> <span class="ruby-identifier">accept</span>(<span class="ruby-identifier">k</span>), <span class="ruby-identifier">accept</span>(<span class="ruby-identifier">v</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">hash</span>

  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!map:(.*)$/</span>, <span class="ruby-regexp">/^!ruby\/hash:(.*)$/</span>
    <span class="ruby-identifier">revive_hash</span> <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>).<span class="ruby-identifier">allocate</span>), <span class="ruby-identifier">o</span>

  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;!omap&#39;</span>, <span class="ruby-string">&#39;tag:yaml.org,2002:omap&#39;</span>
    <span class="ruby-identifier">map</span> = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">psych_omap</span>.<span class="ruby-identifier">new</span>)
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span>,<span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">map</span>[<span class="ruby-identifier">accept</span>(<span class="ruby-identifier">l</span>)] = <span class="ruby-identifier">accept</span> <span class="ruby-identifier">r</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">map</span>

  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!ruby\/marshalable:(.*)$/</span>
    <span class="ruby-identifier">name</span> = <span class="ruby-node">$1</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-identifier">name</span>)
    <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>)

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:init_with</span>)
      <span class="ruby-identifier">init_with</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">revive_hash</span>({}, <span class="ruby-identifier">o</span>), <span class="ruby-identifier">o</span>)
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:marshal_load</span>)
      <span class="ruby-identifier">marshal_data</span> = <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">method</span>(<span class="ruby-value">:accept</span>))
      <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">marshal_load</span>(<span class="ruby-identifier">marshal_data</span>)
      <span class="ruby-identifier">obj</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Cannot deserialize #{name}&quot;</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">revive_hash</span>(<span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, {}), <span class="ruby-identifier">o</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-visit_Psych_Nodes_Scalar" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">visit_Psych_Nodes_Scalar</span><span
                                class="method-args">(o)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="visit_Psych_Nodes_Scalar-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 129</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">visit_Psych_Nodes_Scalar</span> <span class="ruby-identifier">o</span>
  <span class="ruby-identifier">register</span> <span class="ruby-identifier">o</span>, <span class="ruby-identifier">deserialize</span>(<span class="ruby-identifier">o</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-visit_Psych_Nodes_Sequence" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">visit_Psych_Nodes_Sequence</span><span
                                class="method-args">(o)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="visit_Psych_Nodes_Sequence-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 133</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">visit_Psych_Nodes_Sequence</span> <span class="ruby-identifier">o</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-ivar">@load_tags</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>])
    <span class="ruby-identifier">instance</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:init_with</span>)
      <span class="ruby-identifier">coder</span> = <span class="ruby-constant">Psych</span><span class="ruby-operator">::</span><span class="ruby-constant">Coder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>)
      <span class="ruby-identifier">coder</span>.<span class="ruby-identifier">seq</span> = <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }
      <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">init_with</span> <span class="ruby-identifier">coder</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">return</span> <span class="ruby-identifier">instance</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">register_empty</span>(<span class="ruby-identifier">o</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;!omap&#39;</span>, <span class="ruby-string">&#39;tag:yaml.org,2002:omap&#39;</span>
    <span class="ruby-identifier">map</span> = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-constant">Psych</span><span class="ruby-operator">::</span><span class="ruby-constant">Omap</span>.<span class="ruby-identifier">new</span>)
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">map</span>[<span class="ruby-identifier">accept</span>(<span class="ruby-identifier">a</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">first</span>)] = <span class="ruby-identifier">accept</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">last</span>
    }
    <span class="ruby-identifier">map</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!(?:seq|ruby\/array):(.*)$/</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>)
    <span class="ruby-identifier">list</span>  = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>)
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }
    <span class="ruby-identifier">list</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">register_empty</span>(<span class="ruby-identifier">o</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-visit_Psych_Nodes_Stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">visit_Psych_Nodes_Stream</span><span
                                class="method-args">(o)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="visit_Psych_Nodes_Stream-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 323</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">visit_Psych_Nodes_Stream</span> <span class="ruby-identifier">o</span>
  <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-build_exception" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          build_exception(klass, message)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Create an exception with class <code>klass</code> and <code>message</code></p>

                              <div class="method-source-code" id="build_exception-source">
            <pre>static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg)
{
    VALUE e = rb_obj_alloc(klass);

    rb_iv_set(e, &quot;mesg&quot;, mesg);

    return e;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-deduplicate" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">deduplicate</span><span
                                class="method-args">(key)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="deduplicate-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 385</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">deduplicate</span> <span class="ruby-identifier">key</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
    <span class="ruby-comment"># It is important to untaint the string, otherwise it won&#39;t</span>
    <span class="ruby-comment"># be deduplicated into an fstring, but simply frozen.</span>
    <span class="ruby-operator">-</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">untaint</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">key</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-deserialize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">deserialize</span><span
                                class="method-args">(o)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="deserialize-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 51</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">deserialize</span> <span class="ruby-identifier">o</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-ivar">@load_tags</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>])
    <span class="ruby-identifier">instance</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:init_with</span>)
      <span class="ruby-identifier">coder</span> = <span class="ruby-constant">Psych</span><span class="ruby-operator">::</span><span class="ruby-constant">Coder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>)
      <span class="ruby-identifier">coder</span>.<span class="ruby-identifier">scalar</span> = <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
      <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">init_with</span> <span class="ruby-identifier">coder</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">return</span> <span class="ruby-identifier">instance</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">quoted</span>
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@ss</span>.<span class="ruby-identifier">tokenize</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">tag</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;!binary&#39;</span>, <span class="ruby-string">&#39;tag:yaml.org,2002:binary&#39;</span>
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">&#39;m&#39;</span>).<span class="ruby-identifier">first</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!(?:str|ruby\/string)(?::(.*))?$/</span>, <span class="ruby-string">&#39;tag:yaml.org,2002:str&#39;</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">resolve_class</span>(<span class="ruby-node">$1</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span>
      <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>.<span class="ruby-identifier">replace</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;!ruby/object:BigDecimal&#39;</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;bigdecimal&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span> <span class="ruby-constant">BigDecimal</span>
    <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">big_decimal</span>.<span class="ruby-identifier">_load</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;!ruby/object:DateTime&quot;</span>
    <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">date_time</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;date&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span> <span class="ruby-constant">DateTime</span>
    <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@ss</span>.<span class="ruby-identifier">parse_time</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>)
    <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">civil</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">t</span>.<span class="ruby-identifier">to_a</span>[<span class="ruby-value">0</span>, <span class="ruby-value">6</span>].<span class="ruby-identifier">reverse</span>, <span class="ruby-constant">Rational</span>(<span class="ruby-identifier">t</span>.<span class="ruby-identifier">utc_offset</span>, <span class="ruby-value">86400</span>)) <span class="ruby-operator">+</span>
      (<span class="ruby-identifier">t</span>.<span class="ruby-identifier">subsec</span><span class="ruby-operator">/</span><span class="ruby-value">86400</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;!ruby/encoding&#39;</span>
    <span class="ruby-operator">::</span><span class="ruby-constant">Encoding</span>.<span class="ruby-identifier">find</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;!ruby/object:Complex&quot;</span>
    <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">complex</span>
    <span class="ruby-constant">Complex</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;!ruby/object:Rational&quot;</span>
    <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">rational</span>
    <span class="ruby-constant">Rational</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;!ruby/class&quot;</span>, <span class="ruby-string">&quot;!ruby/module&quot;</span>
    <span class="ruby-identifier">resolve_class</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;tag:yaml.org,2002:float&quot;</span>, <span class="ruby-string">&quot;!float&quot;</span>
    <span class="ruby-constant">Float</span>(<span class="ruby-ivar">@ss</span>.<span class="ruby-identifier">tokenize</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>))
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;!ruby/regexp&quot;</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">regexp</span>
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^\/(.*)\/([mixn]*)$/m</span>
    <span class="ruby-identifier">source</span>  = <span class="ruby-node">$1</span>
    <span class="ruby-identifier">options</span> = <span class="ruby-value">0</span>
    <span class="ruby-identifier">lang</span>    = <span class="ruby-keyword">nil</span>
    (<span class="ruby-node">$2</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;&#39;</span>).<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;&#39;</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">option</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">option</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;x&#39;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">options</span> <span class="ruby-operator">|=</span> <span class="ruby-constant">Regexp</span><span class="ruby-operator">::</span><span class="ruby-constant">EXTENDED</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;i&#39;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">options</span> <span class="ruby-operator">|=</span> <span class="ruby-constant">Regexp</span><span class="ruby-operator">::</span><span class="ruby-constant">IGNORECASE</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;m&#39;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">options</span> <span class="ruby-operator">|=</span> <span class="ruby-constant">Regexp</span><span class="ruby-operator">::</span><span class="ruby-constant">MULTILINE</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;n&#39;</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">options</span> <span class="ruby-operator">|=</span> <span class="ruby-constant">Regexp</span><span class="ruby-operator">::</span><span class="ruby-constant">NOENCODING</span>
      <span class="ruby-keyword">else</span> <span class="ruby-identifier">lang</span> = <span class="ruby-identifier">option</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span>[<span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">lang</span>].<span class="ruby-identifier">compact</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;!ruby/range&quot;</span>
    <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">range</span>
    <span class="ruby-identifier">args</span> = <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/([.]{2,3})/</span>, <span class="ruby-value">2</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">accept</span> <span class="ruby-constant">Nodes</span><span class="ruby-operator">::</span><span class="ruby-constant">Scalar</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">s</span>)
    }
    <span class="ruby-identifier">args</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">1</span>) <span class="ruby-operator">==</span> <span class="ruby-string">&#39;...&#39;</span>)
    <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^!ruby\/sym(bol)?:?(.*)?$/</span>
    <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">symbolize</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@ss</span>.<span class="ruby-identifier">tokenize</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-init_with" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">init_with</span><span
                                class="method-args">(o, h, node)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="init_with-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 412</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">init_with</span> <span class="ruby-identifier">o</span>, <span class="ruby-identifier">h</span>, <span class="ruby-identifier">node</span>
  <span class="ruby-identifier">c</span> = <span class="ruby-constant">Psych</span><span class="ruby-operator">::</span><span class="ruby-constant">Coder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">node</span>.<span class="ruby-identifier">tag</span>)
  <span class="ruby-identifier">c</span>.<span class="ruby-identifier">map</span> = <span class="ruby-identifier">h</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:init_with</span>)
    <span class="ruby-identifier">o</span>.<span class="ruby-identifier">init_with</span> <span class="ruby-identifier">c</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">h</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-value">:&quot;@#{k}&quot;</span>, <span class="ruby-identifier">v</span>) }
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">o</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-merge_key" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">merge_key</span><span
                                class="method-args">(hash, key, val)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="merge_key-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 404</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">merge_key</span> <span class="ruby-identifier">hash</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-register" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">register</span><span
                                class="method-args">(node, object)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="register-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 333</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">register</span> <span class="ruby-identifier">node</span>, <span class="ruby-identifier">object</span>
  <span class="ruby-ivar">@st</span>[<span class="ruby-identifier">node</span>.<span class="ruby-identifier">anchor</span>] = <span class="ruby-identifier">object</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">anchor</span>
  <span class="ruby-identifier">object</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-register_empty" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">register_empty</span><span
                                class="method-args">(object)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="register_empty-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 338</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">register_empty</span> <span class="ruby-identifier">object</span>
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">object</span>, [])
  <span class="ruby-identifier">object</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">accept</span> <span class="ruby-identifier">c</span> }
  <span class="ruby-identifier">list</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-resolve_class" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">resolve_class</span><span
                                class="method-args">(klassname)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Convert <code>klassname</code> to a Class</p>

                              <div class="method-source-code" id="resolve_class-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 425</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">resolve_class</span> <span class="ruby-identifier">klassname</span>
  <span class="ruby-identifier">class_loader</span>.<span class="ruby-identifier">load</span> <span class="ruby-identifier">klassname</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-revive" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">revive</span><span
                                class="method-args">(klass, node)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="revive-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 407</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">revive</span> <span class="ruby-identifier">klass</span>, <span class="ruby-identifier">node</span>
  <span class="ruby-identifier">s</span> = <span class="ruby-identifier">register</span>(<span class="ruby-identifier">node</span>, <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>)
  <span class="ruby-identifier">init_with</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">revive_hash</span>({}, <span class="ruby-identifier">node</span>, <span class="ruby-keyword">true</span>), <span class="ruby-identifier">node</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-revive_hash" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">revive_hash</span><span
                                class="method-args">(hash, o, tagged= false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="revive_hash-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/visitors/to_ruby.rb, line 344</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">revive_hash</span> <span class="ruby-identifier">hash</span>, <span class="ruby-identifier">o</span>, <span class="ruby-identifier">tagged</span>= <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">o</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">key</span> = <span class="ruby-identifier">accept</span>(<span class="ruby-identifier">k</span>)
    <span class="ruby-identifier">val</span> = <span class="ruby-identifier">accept</span>(<span class="ruby-identifier">v</span>)

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;&lt;&lt;&#39;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">tag</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;tag:yaml.org,2002:str&quot;</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">v</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">Nodes</span><span class="ruby-operator">::</span><span class="ruby-constant">Alias</span>, <span class="ruby-constant">Nodes</span><span class="ruby-operator">::</span><span class="ruby-constant">Mapping</span>
        <span class="ruby-keyword">begin</span>
          <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">val</span>
        <span class="ruby-keyword">rescue</span> <span class="ruby-constant">TypeError</span>
          <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">val</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">Nodes</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span>
        <span class="ruby-keyword">begin</span>
          <span class="ruby-identifier">h</span> = {}
          <span class="ruby-identifier">val</span>.<span class="ruby-identifier">reverse_each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">h</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">value</span>
          <span class="ruby-keyword">end</span>
          <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">h</span>
        <span class="ruby-keyword">rescue</span> <span class="ruby-constant">TypeError</span>
          <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">val</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">val</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">tagged</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@symbolize_names</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
        <span class="ruby-identifier">key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span>
      <span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@freeze</span>
        <span class="ruby-identifier">key</span> = <span class="ruby-identifier">deduplicate</span>(<span class="ruby-identifier">key</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">val</span>
    <span class="ruby-keyword">end</span>

  }
  <span class="ruby-identifier">hash</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

